package com.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.entity.Suppiler;
import com.entity.SuppilerAccountDetail;
import com.service.SuppilerAccountDetailService;
import com.service.SuppilerService;

@Controller
@RequestMapping("/zhangdan")
public class AccountController {
	@Autowired
	SuppilerAccountDetailService suppilerAccountDetailService;
	
	@Autowired
	SuppilerService suppilerService;
	
	@RequestMapping("/list")
	public String list(Model model){
		List<SuppilerAccountDetail> suppilerAccountDetatil =suppilerAccountDetailService.selectAlls();
		List<Suppiler>supiler =suppilerService.selectAll();
		model.addAttribute("suppilerAccountDetatil", suppilerAccountDetatil);
		model.addAttribute("supiler", supiler);
		return "developer/zhangdan";
	}
	@RequestMapping("/lists")
	public String lists(Integer accountId,String rudate,Model model){
		System.out.println(accountId);
		String str = ""+rudate;
		Date rudate2= new Date();
		SimpleDateFormat format= new SimpleDateFormat("yyyy年MM月dd");
		if(accountId==null){
			accountId=0;
		}
		try {
			if(rudate==null || "".equals(rudate)){
			    str="0000年00月00";
				rudate2=format.parse("");
			}else{
				rudate2=format.parse(str);
			}
			str=""+rudate2;
			System.err.println(rudate2);
		
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(str);
		List<SuppilerAccountDetail> suppilerAccount = suppilerAccountDetailService.selectAccount(accountId,str);
		model.addAttribute("suppilerAccountDetatil", suppilerAccount);
		return "developer/zhangdan";
	}

}

